package com.gjs.intranet.service.impl;

import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gjs.intranet.mapper.LibraryProjectMapper;
import com.gjs.intranet.pojo.dto.LibraryProjectQueryDTO;
import com.gjs.intranet.pojo.entity.LibraryProject;
import com.gjs.intranet.service.ILibraryProjectService;
import org.springframework.stereotype.Service;
import org.springframework.util.NumberUtils;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 项目表 服务实现类
 * </p>
 *
 * @author JC_Ho
 * @since 2022-04-11
 */
@Service
public class LibraryProjectServiceImpl extends ServiceImpl<LibraryProjectMapper, LibraryProject> implements ILibraryProjectService {
    @Override
    public Wrapper<LibraryProject> buildWrapper(LibraryProjectQueryDTO queryDTO){
        LambdaQueryWrapper<LibraryProject> wrapper = new LambdaQueryWrapper<>();

        wrapper.eq(queryDTO.getId() != null && queryDTO.getId() > 0,LibraryProject::getId,queryDTO.getId());
        wrapper.eq(queryDTO.getBookId() != null && queryDTO.getBookId() > 0,LibraryProject::getBookId,queryDTO.getBookId());
        wrapper.eq(!StringUtils.isEmpty(queryDTO.getUnionProjectSn()),LibraryProject::getUnionProjectSn,queryDTO.getUnionProjectSn());
        wrapper.eq(!StringUtils.isEmpty(queryDTO.getErpProjectSn()),LibraryProject::getErpProjectSn,queryDTO.getErpProjectSn());
        wrapper.eq(!StringUtils.isEmpty(queryDTO.getEditorName()),LibraryProject::getEditorName,queryDTO.getEditorName());

        return wrapper;
    }
}
